<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
<head>
<title>_未处理订单</title>
<!-- jedate -->
<link rel="stylesheet" type="text/css"
	href="${ctx}/static/v2/js/plugins/jedate/skin/jedate.css">
<script src="${ctx}/static/v2/js/plugins/jedate/jedate.js"
	type="text/javascript"></script>

<script type="text/javascript">
	//锁定超区件
	var lockOutScopeOrderno = new Array();

	var single_array = new Array();
	var multi_array = new Array();
	var single_b_array = new Array();//单品时，每个批次的订单号
	var multi_b_array = new Array();//单品时，每个批次的订单号
	var customerCode = '';
	var companyCode = '';
	var warehouseCode = '';
	var psCompanyCode = '';
	var seCompanyCode = '';

	var wpcMap = new Array();

	<c:forEach items="${wpcList}" var="wpc">
	wpcMap["${wpc.customerCode}:${wpc.warehouseCode}:${wpc.sku}"] = "${wpc.wholePileQty}";
	</c:forEach>

	function query() {
		customerCode = $("#_customerCode").val();
		companyCode = $("#_companyCode").val();
		warehouseCode = $("#_warehouseCode").val();

		if (!warehouseCode) {
			jAlert("请选择仓库!", "温馨提示");
			return;
		}
		psCompanyCode = $("#_psCompanyCode").val();
		if (companyCode == '-2' && (!psCompanyCode)) {
			jAlert("选择未指定快递时,必须选择派送快递!", "温馨提示");
			return;
		}
		if (psCompanyCode && companyCode != psCompanyCode) {
			if (companyCode == 'MJZT') {
				jAlert("自提客户派送快递必须是【买家自提】", "温馨提示");
				return;
			}
			if (psCompanyCode == 'MJZT') {
				jAlert("非自提客户派送快递不能选择【买家自提】", "温馨提示");
				return;
			}

		}
		if ("${isLockOutScopeOrderno}" != "on") {
			var lockStr = "";
			$("input[name='single_myChecked']:checked").each(function(i, o) {
				lockStr += $(o).val() + ",";
			});
			$("input[name='multi_myChecked']:checked").each(function(i, o) {
				lockStr += $(o).val() + ",";
			});
			lockStr = lockStr.substring(0, lockStr.length - 1);
			$("#lockOutScopeOrdernoStr").val(lockStr);
		}
		$("#queryForm").submit();
	}
	var allIsLockOutScopeOrderno = null;
	$(function() {
		$("#queryForm").validate();
		$("input[type='checkbox']").attr("checked", false);
		jeDate({
			dateCell : "#_fromDate",
			format : "YYYY-MM-DD hh:mm",
			isinitVal : true,
			isTime : true,
			festival : true, //显示节日
			maxDate : jeDate.now(0), //1代表明天，2代表后天，以此类推
		})
		jeDate({
			dateCell : "#_toDate",
			format : "YYYY-MM-DD hh:mm",
			isinitVal : true,
			isTime : true,
			festival : true, //显示节日
			maxDate : jeDate.now(0), //1代表明天，2代表后天，以此类推
		})
		$('#_fromDate')
				.click(
						function() {
							$('.jedatehms').empty();
							var resetSec = '<li><em>00</em><i>:</i></li><li><em>00</em><i>:</i></li><li><em>00</em></li>'
							$('.jedatehms').append(resetSec);
						})
		$('#_toDate')
				.click(
						function() {
							$('.jedatehms').empty();
							var resetSec = '<li><em>23</em><i>:</i></li><li><em>59</em><i>:</i></li><li><em>00</em></li>'
							$('.jedatehms').append(resetSec);
						})
		customerCode = '${customerCode}';
		companyCode = '${companyCode}';
		seCompanyCode = companyCode;
		companyCode = (companyCode == "-1" || companyCode == "-2") ? ""
				: companyCode;
		warehouseCode = '${warehouseCode}';
		psCompanyCode = '${psCompanyCode}';

		var totalListCount = '${totalListCount}';
		var isHaveNotSetRegionalLevel = '${isHaveNotSetRegionalLevel}';
		if (isHaveNotSetRegionalLevel > 0) {
			var msg = "当前订单数【" + totalListCount + "】个，系统预处理未完成订单数【"
					+ isHaveNotSetRegionalLevel + "】个";
			if ((parseInt(totalListCount) - parseInt(isHaveNotSetRegionalLevel)) > 0)
				msg += "，可稍后再查询或立即对本次结果进行处理";
			else
				msg += "，请稍后再查询";
			jAlert(msg, "温馨提示");
		}

		// 	　使用jQuery实现 
		$("#queryForm :input").change(function() {
			$("#queryForm").data("changed", true);
		});

		//超区件
		// 	 var outScope='${param._outScope}';
		// 	 if(outScope=='on'){
		// 	   $("#_outScope").attr("checked",true);
		// 		 $("#_outScope").iCheck('check'); 
		// 		 allIsLockOutScopeOrderno ='on';
		// 	 }else{
		// 	   $("#_outScope").attr("checked",false);
		// 		 $("#_outScope").iCheck('uncheck');
		// 		 allIsLockOutScopeOrderno = null;
		// 	 }

		//是否锁定订单
		var isLockOutScopeOrderno = '${isLockOutScopeOrderno}';
		if (isLockOutScopeOrderno == 'on') {
			$("#_lockOutScopeOrderno").iCheck('check');
		} else {
			$("#_lockOutScopeOrderno").iCheck('uncheck');
		}
		//绑定checkbox
		bindCheckBox("single_myCheckedAll", "single_myChecked");
		bindCheckBox("multi_myCheckedAll", "multi_myChecked");

	});

	//全选事件
	function myCheckedAll(item) {
		$("input[name='" + item + "_myChecked']").prop('checked',
				$("#" + item + "_myCheckedAll").is(":checked"));
		// 	$("input[name='"+item+"_myChecked']").attr("checked",$("#"+item+"_myCheckedAll").is(":checked"));
	}

	//单选事件	
	function myChecked(type, item) {
		// 	if ($("#"+type+"_check" + item).is(":checked")) {
		// 	} else {
		// 		$("#"+type+"_myCheckedAll").attr("checked", false);
		// 		$("#"+type+"_myCheckedAll").prop("checked",false);
		// 	}
	}

	//显示or隐藏
	function showOrHide(flag, i) {
		var type;
		if (flag == 1) {
			type = "single";
		} else {
			type = "multi";
		}
		var temp = $("#" + type + "_batch_" + i);

		if (temp.css("display") == "table") {
			temp.css("display", "none");
		} else {
			$("[name='showOrHideDiv']").css("display", "none");
			temp.css("display", "table");
		}

	}

	//预览作业批次_单件
	function preWorkBatch_single() {
		single_array.length = 0;
		single_b_array.length = 0;
		var preContent = $("#preContent_single");
		preContent.html("");
		if ($("#queryForm").data("changed")) {
			jAlert("搜索条件有修改,请重新搜索才能保存！", "温馨提示");
			return;
		}
		var checkArray = $("input[name='single_myChecked']:checked");
		if (checkArray.length == 0) {
			jAlert("请选择单件商品！", "温馨提示");
			return;
		}

		if (warehouseCode == '') {
			jAlert("请选择出货仓库...", "温馨提示");
			return;
		}
		//huwenjun 判断快递是否超区，快递公司和派送快递是否一样，两个条件满足则不允许生成批次
		var scopeFilter = '${param._scopeFilter}';
		if (scopeFilter == '2'
				&& $("#_companyCode").val() == $("#_psCompanyCode").val()) {
			jAlert("超区件无法生成批次", "温馨提示");
			return;
		}
		var billType = $("#single_billType").val();
		if (billType == '') {
			jAlert("请选择运单类型...", "温馨提示");
			return;
		}
		if (!seCompanyCode) {
			jAlert("不能选择全部快递公司生成批次!", "温馨提示");
			return;
		}
		if (seCompanyCode == '-1') {
			jAlert("不能选择已指定快递生成批次!", "温馨提示");
			return;
		}

		if (seCompanyCode == '-2' && (!psCompanyCode)) {
			jAlert("选择未指定快递时,必须选择派送快递!", "温馨提示");
			return;
		}

		var flowType = $("#single_flowType").val();
		if (flowType == '') {
			jAlert("请选择作业模式...", "温馨提示");
			return;
		}
		//       var open = false;
		checkArray.each(function() {
			var orderno = $(this).val();
			//          if($("#single_cacode_"+orderno).html()){
			//          	open = true;
			//          }
			single_array.push(orderno);
		});
		if (scopeFilter == '2'
				&& $("#_companyCode").val() != $("#_psCompanyCode").val()) {
			jConfirm("您选择的派送快递与客户指定快递不一致，请慎重操作!", "温馨提醒", function(result) {
				if (result) {
					$("#single_preWorkBatch").trigger("click");
				}
			});
		}
		if (seCompanyCode != '-2' && seCompanyCode != psCompanyCode) {
			//       if(open){
			jConfirm("您选择的派送快递与客户指定快递不一致，请慎重操作!", "温馨提醒", function(result) {
				if (result) {
					$("#single_preWorkBatch").trigger("click");
				}
			});
		} else {
			$("#single_preWorkBatch").trigger("click");
		}

		var tacticsType = $("#_tacticsType").val();
		var orderNum = $("#single_orderNum").val();
		var flag = 0;
		var str = "";
		var batchNum = 0;
		var sku_last = '';
		var b_orders;
		var index = 0;
		if (tacticsType == 'wholePile') {
			var batchArray = new Array();

			var batchMap = new Array();
			var countSku = count(single_array, 'single_sku_');
			for (i = 0; i < single_array.length; i++) {
				flag++;
				var orderno = single_array[i];
				var shopna = $("#single_shopna_" + orderno).html();
				var crtime = $("#single_crtime_" + orderno).html();
				var sku = $("#single_sku_" + orderno).html();

				var key = customerCode + ":" + warehouseCode + ":" + sku;

				var wholePileQty = wpcMap[key];
				if (typeof (wholePileQty) == "undefined") {
					continue;
				}
				var result = false;
				for (var b = 0; b < batchArray.length; b++) {
					if (batchArray[b] == key) {
						result = true;
						break;
					}
				}
				if (!result) {
					batchArray.push(key);
				}
				if (batchMap[key]) {
					if (batchMap[key][batchMap[key].length - 1].length < wholePileQty) {
						batchMap[key][batchMap[key].length - 1].push({
							"orderno" : orderno,
							"shopna" : shopna,
							"crtime" : crtime,
							"sku" : sku
						});
					} else {
						batchMap[key].push([ {
							"orderno" : orderno,
							"shopna" : shopna,
							"crtime" : crtime,
							"sku" : sku
						} ]);
					}
				} else {
					batchMap[key] = new Array();
					batchMap[key].push([ {
						"orderno" : orderno,
						"shopna" : shopna,
						"crtime" : crtime,
						"sku" : sku
					} ]);
				}
			}

			flag = 1;
			var batchShowList = new Array();

			str += "<table id='contentTable'  class='table table-bordered'>";
			str += "<thead><th style='vertical-align: middle; color: white; ' colspan=5 bgcolor='#8EB4CB'>单件作业批次（"
					+ (++batchNum)
					+ "）<button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick='showOrHide(1,"
					+ batchNum
					+ ");'>查看明细</button><button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick=createWorkBatch_single("
					+ (++index) + ");>创建批次</button></th></thead>";
			str += "</table>";
			str += "<table id='single_batch_"+batchNum+"' name='showOrHideDiv' style='display:none; margin-top: -20px;' class='table table-bordered'>";
			str += "<thead><tr><th>序号</th><th>订单号</th><th>SKU</th><th>来源店铺</th><th>审单时间 </th></tr></thead><tbody>";

			for (var i = 0; i < batchArray.length; i++) {
				var key = batchArray[i];
				var batchItems = batchMap[key];
				var wholePileQty = wpcMap[key];

				for (var j = 0; j < batchItems.length; j++) {
					var batchItem = batchItems[j];
					if (batchItem.length == wholePileQty) {
						b_orders = new Array();
						single_b_array[index] = b_orders;

						for (var q = 0; q < batchItem.length; q++) {
							var orderno = batchItem[q].orderno;
							var sku = batchItem[q].sku;
							var shopna = batchItem[q].shopna;
							var crtime = batchItem[q].crtime;
							str += "<tr>";
							str += "<td>" + flag + "</td>";
							str += "<td>" + orderno + "</td>";
							str += "<td>" + sku + "</td>";
							str += "<td>" + shopna + "</td>";
							str += "<td>" + crtime + "</td>";
							str += "</tr>";
							b_orders.push(orderno);
							flag++;
						}

					}
				}
			}
			str += "</tbody></table>";
		} else if (tacticsType == 'onesku') {
			var countSku = count(single_array, 'single_sku_');
			for (i = 0; i < single_array.length; i++) {
				flag++;
				var orderno = single_array[i];
				var shopna = $("#single_shopna_" + orderno).html();
				var crtime = $("#single_crtime_" + orderno).html();
				var sku = $("#single_sku_" + orderno).html();

				if (sku_last != sku) {
					sku_last = sku;
					b_orders = new Array();
					single_b_array[index] = b_orders;
					b_orders.push(orderno);
					str += "<table id='contentTable'  class='table table-bordered'>";
					str += "<thead><th style='vertical-align: middle; color: white; ' colspan=4 bgcolor='#8EB4CB'>单件作业批次("
							+ (++batchNum)
							+ ")数量(<font color='red'>"
							+ countSku[index]
							+ "</font>)<button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick='showOrHide(1,"
							+ batchNum
							+ ");'>查看明细</button><button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick=createWorkBatch_single("
							+ index++ + ",this);>创建批次</button></th></thead>";
					str += "</table>";
					str += "<table id='single_batch_"+batchNum+"' name='showOrHideDiv' style='display:none; margin-top: -20px;' class='table table-bordered'>";
					str += "<thead><tr><th>序号</th><th>订单号</th><th>来源店铺</th><th>审单时间 </th></tr></thead><tbody>";
				} else {
					b_orders.push(orderno);
				}
				str += "<tr>";
				str += "<td>" + flag + "</td>";
				str += "<td>" + orderno + "</td>";
				str += "<td>" + shopna + "</td>";
				str += "<td>" + crtime + "</td>";
				str += "</tr>";
			}
		} else if (tacticsType == 'promotion') {
			var countSku = count(single_array, 'single_sku_');
			for (i = 0; i < single_array.length; i++) {
				flag++;
				var orderno = single_array[i];
				var shopna = $("#single_shopna_" + orderno).html();
				var crtime = $("#single_crtime_" + orderno).html();
				var sku = $("#single_sku_" + orderno).html();

				if (sku_last != sku) {
					sku_last = sku;
					b_orders = new Array();
					single_b_array[index] = b_orders;
					b_orders.push(orderno);
					str += "<table id='contentTable'  class='table table-bordered'>";
					str += "<thead><th style='vertical-align: middle; color: white; ' colspan=4 bgcolor='#8EB4CB'>单件作业批次("
							+ (++batchNum)
							+ ")数量(<font color='red'>"
							+ countSku[index]
							+ "</font>)<button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick='showOrHide(1,"
							+ batchNum
							+ ");'>查看明细</button><button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick=createWorkBatch_single("
							+ index++ + ",this);>创建批次</button></th></thead>";
					str += "</table>";
					str += "<table id='single_batch_"+batchNum+"' name='showOrHideDiv' style='display:none; margin-top: -20px;' class='table table-bordered'>";
					str += "<thead><tr><th>序号</th><th>订单号</th><th>来源店铺</th><th>审单时间 </th></tr></thead><tbody>";
				} else {
					b_orders.push(orderno);
				}
				str += "<tr>";
				str += "<td>" + flag + "</td>";
				str += "<td>" + orderno + "</td>";
				str += "<td>" + shopna + "</td>";
				str += "<td>" + crtime + "</td>";
				str += "</tr>";
			}
		} else {
			for (i = 0; i < single_array.length; i++) {
				flag++;
				var orderno = single_array[i];
				var shopna = $("#single_shopna_" + orderno).html();
				var crtime = $("#single_crtime_" + orderno).html();

				if (flag % orderNum == 1) {
					b_orders = new Array();
					single_b_array[index] = b_orders;
					b_orders.push(orderno);
					str += "<table id='contentTable'  class='table table-bordered'>";
					str += "<thead><th style='vertical-align: middle; color: white; ' colspan=4 bgcolor='#8EB4CB'>单件作业批次（"
							+ (++batchNum)
							+ "）<button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick='showOrHide(1,"
							+ batchNum
							+ ");'>查看明细</button><button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick=createWorkBatch_single("
							+ index++ + ");>创建批次</button></th></thead>";
					str += "</table>";
					str += "<table id='single_batch_"+batchNum+"' name='showOrHideDiv' style='display:none; margin-top: -20px;' class='table table-bordered'>";
					str += "<thead><tr><th>序号</th><th>订单号</th><th>来源店铺</th><th>审单时间 </th></tr></thead><tbody>";
				} else {
					b_orders.push(orderno);
				}

				str += "<tr>";
				str += "<td>" + flag + "</td>";
				str += "<td>" + orderno + "</td>";
				str += "<td>" + shopna + "</td>";
				str += "<td>" + crtime + "</td>";
				str += "</tr>";

				if (flag % orderNum == 0) {
					str += "</tbody></table>";
				}
			}

		}
		preContent.html(str);

	}

	function count(orders, type) {
		var rs = new Array();
		var last_sku = '';
		var index = -1;
		for (var i = 0; i < orders.length; i++) {
			var orderno = orders[i];
			var sku = $("#" + type + orderno).html();
			if (last_sku != sku) {
				last_sku = sku;
				rs[++index] = 1;
			} else {
				rs[index] = rs[index] + 1;
			}
		}
		return rs;
	}

	//预览作业批次_多件
	function preWorkBatch_multi() {
		multi_array.length = 0;
		var preContent = $("#preContent_multi");
		preContent.html("");
		if ($("#queryForm").data("changed")) {
			jAlert("搜索条件有修改,请重新搜索才能保存！", "温馨提示");
			return;
		}
		var checkArray = $("input[name='multi_myChecked']:checked");
		if (checkArray.length == 0) {
			jAlert("请选择多件商品！", "温馨提示");
			return;
		}

		if (warehouseCode == '') {
			jAlert("请选择出货仓库...", "温馨提示");
			return;
		}
		//huwenjun
		var scopeFilter = '${param._scopeFilter}';
		if (scopeFilter == '2'
				&& $("#_companyCode").val() == $("#_psCompanyCode").val()) {
			jAlert("超区件无法生成批次", "温馨提示");
			return;
		}
		var billType = $("#multi_billType").val();
		if (billType == '') {
			jAlert("请选择运单类型...", "温馨提示");
			return;
		}
		if (!seCompanyCode) {
			jAlert("不能选择全部快递公司生成批次!", "温馨提示");
			return;
		}
		if (seCompanyCode == '-1') {
			jAlert("不能选择已指定快递生成批次!", "温馨提示");
			return;
		}
		if (seCompanyCode == '-2' && (!psCompanyCode)) {
			jAlert("选择未指定快递时,必须选择派送快递!", "温馨提示");
			return;
		}

		var flowType = $("#multi_flowType").val();
		if (flowType == '') {
			jAlert("请选择作业模式...", "温馨提示");
			return;
		}

		var tacticsType = $("#_tacticsType").val();
		if (tacticsType == 'onesku') {
			jAlert("多件商品，不能使用单品合拣策略。", "温馨提示");
			return;
		}
		if (tacticsType == 'wholePile') {
			jAlert("多件商品，不能使用整托拣选策略。", "温馨提示");
			return;
		}

		//       var open = false;
		checkArray.each(function() {
			var orderno = $(this).val();
			//          if($("#multi_cacode_"+orderno).html()){
			//          	open = true;
			//          }
			multi_array.push(orderno);
		});
		if (scopeFilter == '2'
				&& $("#_companyCode").val() != $("#_psCompanyCode").val()) {
			jConfirm("您选择的派送快递与客户指定快递不一致，请慎重操作!", "温馨提醒", function(result) {
				if (result) {
					$("#multi_preWorkBatch").trigger("click");
				}
			});
		}
		if (seCompanyCode != '-2' && seCompanyCode != psCompanyCode) {
			//    if(open){
			jConfirm("您选择的派送快递与客户指定快递不一致，请慎重操作!", "温馨提醒", function(result) {
				if (result) {
					$("#multi_preWorkBatch").trigger("click");
				}
			});
		} else {
			$("#multi_preWorkBatch").trigger("click");
		}
		var orderNum = $("#multi_orderNum").val();
		var flag = 0;
		var str = "";
		var batchNum = 0;
		var sku_last = '';
		var b_orders;
		var index = 0;
		if (tacticsType == 'promotion' || tacticsType == "comb") {
			var btn2 = $("#btn_createWorkBatch_multi");
			btn2.attr("disabled", true);
			btn2.attr("class", "btn btn-primary");
			var countSku = count(multi_array, 'multi_sku_');
			for (i = 0; i < multi_array.length; i++) {
				flag++;
				var orderno = multi_array[i];
				var shopna = $("#multi_shopna_" + orderno).html();
				var crtime = $("#multi_crtime_" + orderno).html();
				var sku = $("#multi_sku_" + orderno).html();

				if (sku_last != sku) {
					sku_last = sku;
					b_orders = new Array();
					multi_b_array[index] = b_orders;
					b_orders.push(orderno);
					str += "<table id='contentTable'  class='table table-bordered'>";
					str += "<thead><th style='vertical-align: middle; color: white; ' colspan=4 bgcolor='#8EB4CB'>多件作业批次("
							+ (++batchNum)
							+ ")数量(<font color='red'>"
							+ countSku[index]
							+ "</font>)<button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick='showOrHide(2,"
							+ batchNum
							+ ");'>查看明细</button><button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick=createWorkBatch_mul("
							+ index++ + ",this);>创建批次</button></th></thead>";
					str += "</table>";
					str += "<table id='multi_batch_"+batchNum+"' name='showOrHideDiv' style='display:none; margin-top: -20px;' class='table table-bordered'>";
					str += "<thead><tr><th>序号</th><th>订单号</th><th>来源店铺</th><th>审单时间 </th></tr></thead><tbody>";
				} else {
					b_orders.push(orderno);
				}
				str += "<tr>";
				str += "<td>" + flag + "</td>";
				str += "<td>" + orderno + "</td>";
				str += "<td>" + shopna + "</td>";
				str += "<td>" + crtime + "</td>";
				str += "</tr>";
			}
		} else {
			for (i = 0; i < multi_array.length; i++) {
				flag++;
				var orderno = multi_array[i];
				var shopna = $("#multi_shopna_" + orderno).html();
				var crtime = $("#multi_crtime_" + orderno).html();

				if (flag % orderNum == 1) {
					str += "<table id='contentTable'  class='table table-bordered'>";
					str += "<thead><th style='vertical-align: middle; color: white; ' colspan=4 bgcolor='#8EB4CB'>多件作业批次("
							+ (++batchNum)
							+ ")<a href='#' style='font-style: italic;margin-left: 10px;' onclick='showOrHide(2,"
							+ batchNum
							+ ");'>点击查看</a><button class='btn btn-primary' style='font-style: italic;margin-left: 10px;' onclick=createWorkBatch_multi_by_one("
							+ i
							+ ","
							+ calcLastIndex(i, orderNum, multi_array.length)
							+ ",this);>创建批次</button></th></thead>";
					str += "</table>"
					str += "<table id='multi_batch_"+batchNum+"' name='showOrHideDiv' style='display:none; margin-top: -20px;' class='table table-bordered'>";
					str += "<thead><tr><th>序号</th><th>订单号</th><th>来源店铺</th><th>审单时间 </th></tr></thead><tbody>";
				}

				str += "<tr>";
				str += "<td>" + flag + "</td>";
				str += "<td>" + orderno + "</td>";
				str += "<td>" + shopna + "</td>";
				str += "<td>" + crtime + "</td>";
				str += "</tr>";

				if (flag % orderNum == 0) {
					str += "</tbody></table>";
				}
			}
		}
		preContent.html(str);
	}

	function calcLastIndex(firstIndex, orderNum, arraySize) {
		var lastIndex = parseInt(firstIndex) + parseInt(orderNum);
		if (lastIndex > arraySize) {
			return arraySize;
		} else {
			return lastIndex;
		}
	}

	//创建作业批次_单件
	function createWorkBatch_single(index, button) {
		var btn = $(button);
		btn.attr("disabled", true);
		btn.attr("class", "btn btn-primary");

		var btn2 = $("#btn_createWorkBatch_single");
		btn2.attr("disabled", true);
		btn2.attr("class", "btn btn-primary");

		var orderNum = $("#single_orderNum").val();
		var billType = $("#single_billType").val();
		var flowType = $("#single_flowType").val();
		var psFlag = $("#_psFlag").val();//优先派送标志
		var orders = "";
		var orderData;
		if (index >= 0) {
			orderData = single_b_array[index];
		} else {
			orderData = single_array;
		}
		for (i = 0; i < orderData.length; i++) {
			orders += orderData[i] + "【P】";
		}

		var tacticsType = $("#_tacticsType").val();

		$.ajax({
			type : 'post',
			url : '${ctx}/workBatch/ajaxCreateWorkBatch',
			data : {
				tacticsType : tacticsType,
				pickType : 'single',
				orderNum : orderNum,
				customerCode : customerCode,
				companyCode : companyCode,
				seCompanyCode : seCompanyCode,
				psCompanyCode : psCompanyCode,
				warehouseCode : warehouseCode,
				billType : billType,
				flowType : flowType,
				orders : orders,
				psFlag : psFlag
			},
			dataType : 'json',
			success : function(data) {
				if (data == true) {
					jAlert("创建作业批次成功！", "温馨提示", function() {
						if (index < 0) {
							$("#btn_cancel_single").trigger("click");
							$("#queryForm").submit();
						} else {
							//将本次创建过的订单剔除
							$.each(orderData, function(k, v) {
								$("#tr_single_" + v).remove();
							});
						}

					});

				} else {
					jAlert("创建作业批次失败！", "温馨提示", function() {
						btn.attr("disabled", false);
						btn.attr("class", "btn btn-primary");
					});
				}

			},
			error : function() {
				jAlert("网络繁忙，请稍后重试...", "温馨提示");
				btn.attr("disabled", false);
				btn.css("class", "btn-primary");
			}
		});

	}
	//创建作业批次_单件
	function createWorkBatch_mul(index, button) {
		var btn = $(button);
		btn.attr("disabled", true);
		btn.attr("class", "btn btn-primary");

		var btn2 = $("#btn_createWorkBatch_multi");
		btn2.attr("disabled", true);
		btn2.attr("class", "btn btn-primary");

		var orderNum = $("#multi_orderNum").val();
		var billType = $("#multi_billType").val();
		var flowType = $("#multi_flowType").val();
		var psFlag = $("#_psFlag").val();//优先派送标志
		var orders = "";
		var orderData;
		if (index >= 0) {
			orderData = multi_b_array[index];
		} else {
			orderData = multi_array;
		}
		for (i = 0; i < orderData.length; i++) {
			orders += orderData[i] + "【P】";
		}

		var tacticsType = $("#_tacticsType").val();

		$.ajax({
			type : 'post',
			url : '${ctx}/workBatch/ajaxCreateWorkBatch',
			data : {
				tacticsType : tacticsType,
				pickType : 'multi',
				orderNum : orderNum,
				customerCode : customerCode,
				companyCode : companyCode,
				seCompanyCode : seCompanyCode,
				psCompanyCode : psCompanyCode,
				warehouseCode : warehouseCode,
				billType : billType,
				flowType : flowType,
				orders : orders,
				psFlag : psFlag
			},
			dataType : 'json',
			success : function(data) {
				if (data == true) {
					jAlert("创建作业批次成功！", "温馨提示", function() {
						if (index < 0) {
							$("#btn_cancel_single").trigger("click");
							$("#queryForm").submit();
						} else {
							//将本次创建过的订单剔除
							$.each(orderData, function(k, v) {
								$("#tr_single_" + v).remove();
							});
						}

					});

				} else {
					jAlert("创建作业批次失败！", "温馨提示", function() {
						btn.attr("disabled", false);
						btn.attr("class", "btn btn-primary");
					});
				}

			},
			error : function() {
				jAlert("网络繁忙，请稍后重试...", "温馨提示");
				btn.attr("disabled", false);
				btn.css("class", "btn-primary");
			}
		});

	}

	//创建作业批次_多件
	function createWorkBatch_multi() {
		var btn = $("#btn_createWorkBatch_multi");
		btn.attr("disabled", true);
		btn.attr("class", "btn");

		var orderNum = $("#multi_orderNum").val();
		var billType = $("#multi_billType").val();
		var flowType = $("#multi_flowType").val();
		var psFlag = $("#_psFlag").val();//优先派送标志

		var orders = "";

		for (i = 0; i < multi_array.length; i++) {
			orders += multi_array[i] + "【P】";
		}

		var tacticsType = $("#_tacticsType").val();

		$.ajax({
			type : 'post',
			url : '${ctx}/workBatch/ajaxCreateWorkBatch',
			data : {
				tacticsType : tacticsType,
				pickType : 'multi',
				orderNum : orderNum,
				customerCode : customerCode,
				companyCode : companyCode,
				seCompanyCode : seCompanyCode,
				psCompanyCode : psCompanyCode,
				warehouseCode : warehouseCode,
				billType : billType,
				flowType : flowType,
				orders : orders,
				psFlag : psFlag
			},
			dataType : 'json',
			success : function(data) {
				if (data == true) {
					jAlert("创建作业批次成功！", "温馨提示", function() {
						$("#btn_cancel_multi").trigger("click");
						//$("#queryForm").submit();
					});
				} else {
					jAlert("创建作业批次失败！", "温馨提示");
				}
				btn.attr("disabled", true);
			},
			error : function() {
				jAlert("网络繁忙，请稍后重试...", "温馨提示");
				btn.attr("disabled", true);
			}
		});
	}

	//add 20160620 单独提取出来
	function closeMultiModal() {
		$("#queryForm").submit();
	}

	//创建作业批次_多件 每次只选择一个 add 20160620 bug:343 
	function createWorkBatch_multi_by_one(firstIndex, lastIndex, button) {
		var btn = $(button);
		btn.attr("disabled", true);
		btn.attr("class", "btn btn-primary");

		var orderNum = $("#multi_orderNum").val();
		var billType = $("#multi_billType").val();
		var flowType = $("#multi_flowType").val();
		var psFlag = $("#_psFlag").val();//优先派送标志

		var orderData = multi_array.slice(firstIndex, lastIndex);
		var orders = "";

		for (i = 0; i < orderData.length; i++) {
			orders += orderData[i] + "【P】";
		}

		var tacticsType = $("#_tacticsType").val();

		$.ajax({
			type : 'post',
			url : '${ctx}/workBatch/ajaxCreateWorkBatch',
			data : {
				tacticsType : tacticsType,
				pickType : 'multi',
				orderNum : orderNum,
				customerCode : customerCode,
				companyCode : companyCode,
				seCompanyCode : seCompanyCode,
				psCompanyCode : psCompanyCode,
				warehouseCode : warehouseCode,
				billType : billType,
				flowType : flowType,
				orders : orders,
				psFlag : psFlag
			},
			dataType : 'json',
			success : function(data) {
				if (data == true) {
					jAlert("创建作业批次成功！", "温馨提示", function() {
						btn.attr("disabled", true);
					});
				} else {
					jAlert("创建作业批次失败！", "温馨提示");
				}
			},
			error : function() {
				jAlert("网络繁忙，请稍后重试...", "温馨提示");
				btn.attr("disabled", false);
			}
		});
	}

	//级联商家店铺
	function loadShop(customerCode, sel_shop) {
		$("#" + sel_shop).html("");
		$.ajax({
			type : 'post',
			url : '${ctx}/warehouse/ajaxGetShop',
			data : {
				customerCode : customerCode
			},
			dataType : 'json',
			success : function(data) {
				var shopList = data.shopList;
				var str = "<option value='' selected='selected'></option>";
				$.each(shopList, function(i) {
					var shop = shopList[i];
					str += "<option value='"+shop.shopCode+"'>" + shop.shopName
							+ "</option>";
				});
				$("#" + sel_shop).html(str);
				$("#" + sel_shop).trigger("chosen:updated");
			},
			error : function() {
				jAlert("网络繁忙，请稍后重试...", "温馨提示");
			}
		});
	}

	//级联商家仓库 add 20160530 lianghe.yuan
	function ajaxAreaGroupNew(item) {
		customerCode = item.value;
		$("#_warehouseCode").html("");
		if (customerCode == '') {
			$("#_warehouseCode").html("<option value=''></option>");
			return;
		}
		$
				.ajax({
					type : 'post',
					url : '${ctx}/areaGroup/ajaxAreaGroup',
					data : 'customerCode=' + customerCode,
					dataType : 'json',
					success : function(data) {
						var tempString = "<option value=\"\"></option>";
						if (data.status == "1") {
							$
									.each(
											data.content,
											function(i) {
												if (i == 0) {//默认第一个选中
													tempString += "<option value="+data.content[i].groupCode+" selected=selected>"
															+ data.content[i].groupName;
												} else {
													tempString += "<option value="+data.content[i].groupCode+">"
															+ data.content[i].groupName;
												}
											});
						} else if (data.status == "2") {
							$
									.each(
											data.content.restAreaGroupDtos,
											function(i) {
												tempString += "<option value="+data.content.restAreaGroupDtos[i].areagroupCode+">"
														+ data.content.restAreaGroupDtos[i].areagroupName;
											});
						} else {
							alert(data.content);
						}

						$("#_warehouseCode").html(tempString);
						$("#_warehouseCode").trigger("chosen:updated");

					},
					error : function() {
						alert("获取信息错误！");
					}
				});
	}

	function doSelectCompanyCode() {
		var _companyCode = $("#_companyCode");
		var _psCompanyCode = $("#_psCompanyCode");
		if (!_companyCode.val() || _companyCode.val() == "-1") {
			_psCompanyCode.val("");
			_psCompanyCode.parent().parent().hide();
		} else if (_companyCode.val() == "-2") {
			_psCompanyCode.val("");
			_psCompanyCode.parent().parent().show();
		} else {
			_psCompanyCode.val(_companyCode.val());
			_psCompanyCode.parent().parent().show();
		}
		$("#_psCompanyCode").trigger("chosen:updated");
	}

	//导出含备注订单 
	function exceptRemarkOrdernos() {
		if (customerCode == "") {
			jAlert("请选择商家", " 错误提示");
			return false;
		}
		warehouseCode = $("#_warehouseCode").val()
		if (warehouseCode == "") {
			jAlert("请选择仓库", " 错误提示");
			return false;
		}
		$("#queryForm").attr("action", '${ctx}/workBatch/exceptRemarkOrdernos');
		$("#queryForm").submit();
		$("#queryForm").attr("action", '${ctx}/workBatch/v2_query');

	}
</script>
</head>

<body>


	<section class="content">
		<div class="row">
			<div class="col-md-12">

				<!-- Primary box -->
				<div class="box box-solid box-primary">
					<div class="box-header">
						<i class="fa fa-edit"></i>
						<h3 class="box-title">条件查询</h3>
						<div class="box-tools pull-right">
							<button class="btn btn-primary btn-sm" data-widget="collapse">
								<i class="fa fa-minus"></i>
							</button>
						</div>
					</div>
					<div class="box-body">


						<form class="form-search" id="queryForm" method="post"
							action="${ctx}/workBatch/v2_query" style="margin-top: 10px;">
							<input id="lockOutScopeOrdernoStr" name="_lockOutScopeOrdernoStr"
								type="hidden" value="${lockOutScopeOrdernoStr}" />
							<!-- 					<table class="table table-striped table-bordered table-condensed" style="margin-top: 0px;"> -->
							<!-- 						<thead> -->
							<!-- 							<th style="vertical-align: middle; color: white; " colspan="1" bgcolor="#8EB4CB">订单筛选</th> -->
							<!-- 						</thead> -->

							<!-- 						<tr> -->
							<!-- 						   <td> -->
							<div class="form-group row">

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 商家: </span> <select
											data-placeholder="请选择..." class="form-control searchSelect"
											id="_customerCode" name="_customerCode"
											value="${param._customerCode}"
											onchange="ajaxAreaGroupNew(this,'_warehouseCode');loadShop(this.value,'_shopCode');">
											<option value=""></option>
											<c:forEach items="${customerList}" var="customer">
												<option value="${customer.customerCode}"
													<c:if test="${customerCode eq customer.customerCode }">selected=selected</c:if>>${customer.customerName}</option>
											</c:forEach>
										</select>
									</div>
								</div>


								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 店铺: </span> <select
											class="form-control" id="_shopCode" name="_shopCode"
											value="${param._shopCode}">
											<option value=""></option>
											<c:forEach items="${shopList}" var="shop">
												<option value="${shop.shopCode}"
													<c:if test="${param._shopCode eq shop.shopCode }">selected=selected</c:if>>${shop.shopName}</option>
											</c:forEach>
										</select>
									</div>
								</div>





								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text">仓库: </span> <select
											class="form-control" name="_warehouseCode"
											id="_warehouseCode" class="input-medium">
											<option value=""></option>
											<c:forEach items="${warehouseList}" var="w">
												<option value="${w.groupCode}"
													<c:if test="${warehouseCode eq w.groupCode}">selected=selected</c:if>>${w.groupName}</option>
											</c:forEach>
										</select>
									</div>
								</div>


								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 目的地: </span> <input
											type="text" name="_addres" id="_addres"
											class="form-control span3" value="${param._addres}">
									</div>
								</div>


							</div>
							<div class="form-group row">
								<!-- 						   </td> -->
								<!-- 						</tr> -->
								<!-- 						<tr> -->
								<!-- 						<td> -->

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> &nbsp;审核时间: </span>
										<!-- 										<div class="input-group-addon"> -->
										<!-- 											<i class="fa fa-calendar"></i> -->
										<!-- 										</div> -->
										<input type="text" name="_fromDate" id="_fromDate"
											value="${param._fromDate}" class="form-control required">
									</div>
								</div>

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 至: </span>
										<!-- 										<div class="input-group-addon"> -->
										<!-- 											<i class="fa fa-calendar"></i> -->
										<!-- 										</div> -->
										<input type="text" name="_toDate" id="_toDate"
											value="${param._toDate}" class="form-control required">
									</div>
								</div>
								<script type="text/javascript">
									Date.prototype.Format = function(fmt) { //author: meizz 
										var o = {
											"M+" : this.getMonth() + 1, //月份 
											"d+" : this.getDate(), //日 
											"h+" : this.getHours(), //小时 
											"m+" : this.getMinutes(), //分 
											"s+" : this.getSeconds(), //秒 
											"q+" : Math
													.floor((this.getMonth() + 3) / 3), //季度 
											"S" : this.getMilliseconds()
										//毫秒 
										};
										if (/(y+)/.test(fmt))
											fmt = fmt
													.replace(
															RegExp.$1,
															(this.getFullYear() + "")
																	.substr(4 - RegExp.$1.length));
										for ( var k in o)
											if (new RegExp("(" + k + ")")
													.test(fmt))
												fmt = fmt
														.replace(
																RegExp.$1,
																(RegExp.$1.length == 1) ? (o[k])
																		: (("00" + o[k])
																				.substr(("" + o[k]).length)));
										return fmt;
									}
									<c:if test="${empty param._fromDate}">
									$("#_fromDate")
											.val(
													new Date()
															.Format("yyyy-MM-dd 00:00"));
									</c:if>
									<c:if test="${empty param._toDate}">
									$("#_toDate")
											.val(
													new Date()
															.Format("yyyy-MM-dd 23:59"));
									</c:if>
								</script>
								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 快递公司: </span> <select
											class="form-control" id="_companyCode" name="_companyCode"
											value="${param._companyCode}"
											onchange="doSelectCompanyCode()">
											<option value="">全部</option>
											<option value="-1"
												<c:if test="${param._companyCode eq '-1' }">selected=selected</c:if>>已指定快递</option>
											<%-- 									        <option value="-2" <c:if test="${param._companyCode eq '-2' }">selected=selected</c:if>>未指定快递</option> --%>
											<c:forEach items="${cmpList}" var="cmp">
												<option value="${cmp.companyCode}"
													<c:if test="${param._companyCode eq cmp.companyCode }">selected=selected</c:if>>${cmp.companyName}</option>
											</c:forEach>
										</select>
									</div>
								</div>



								<div class="col-sm-3"
									<c:if test="${empty param._psCompanyCode}">
								 style="display:none;"
								</c:if>>
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 派送快递: </span> <select
											class="form-control" id="_psCompanyCode"
											name="_psCompanyCode" value="${param._companyCode}">
											<option value="">----请选择----</option>
											<c:forEach items="${cmpList}" var="cmp">
												<option value="${cmp.companyCode}"
													<c:if test="${param._psCompanyCode eq cmp.companyCode }">selected=selected</c:if>>${cmp.companyName}</option>
											</c:forEach>
										</select>
									</div>
								</div>



							</div>
							<div class="form-group row">

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 筛选策略: </span> <select
											class="form-control" id="_tacticsType" name="_tacticsType">
											<option value="skufirst"
												<c:if test="${param._tacticsType eq 'skufirst'}">selected="selected"</c:if>>sku集中策略</option>
											<option value="timefirst"
												<c:if test="${param._tacticsType eq 'timefirst'}">selected="selected"</c:if>>时间优先策略</option>
											<option value="onesku"
												<c:if test="${param._tacticsType eq 'onesku'}">selected="selected"</c:if>>单品合拣策略</option>
											<option value="prepkg"
												<c:if test="${param._tacticsType eq 'prepkg'}">selected="selected"</c:if>>预包装策略</option>
											<option value="promotion"
												<c:if test="${param._tacticsType eq 'promotion'}">selected="selected"</c:if>>大促策略</option>
											<option value="comb"
												<c:if test="${param._tacticsType eq 'comb'}">selected="selected"</c:if>>组合策略</option>
										</select>
									</div>
								</div>


								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 需要发票: </span> <select
											class="form-control" id="_isInvoice" name="_isInvoice">
											<option value="">全部</option>
											<option value="1"
												<c:if test="${param._isInvoice eq '1'}">selected="selected"</c:if>>是</option>
											<option value="2"
												<c:if test="${param._isInvoice eq '2'}">selected="selected"</c:if>>否</option>
										</select>
									</div>
								</div>




								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 筛选范围: </span>
										<!-- 										<input type="checkbox" id="_outScope" name="_outScope" style="margin-top: -2px;"/> -->
										<select class="form-control" id="_scopeFilter"
											name="_scopeFilter">
											<option value="1"
												<c:if test="${param._scopeFilter eq '1'}">selected="selected"</c:if>>可达区域</option>
											<option value="2"
												<c:if test="${param._scopeFilter eq '2'}">selected="selected"</c:if>>超区件</option>
											<option value="3"
												<c:if test="${param._scopeFilter eq '3'}">selected="selected"</c:if>>优势区</option>
										</select>
									</div>
								</div>

								<div class="col-sm-1">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 锁定订单: </span> <input
											type="checkbox" id="_lockOutScopeOrderno"
											name="_lockOutScopeOrderno" style="margin-top: -2px;" />
									</div>
								</div>

							</div>

							<div class="form-group row">
								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 单据号: </span> <input
											type="text" name="_documentno" id="_documentno"
											class="form-control span" value="${param._documentno}">
									</div>
								</div>

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 是否优先派送: </span> <select
											class="form-control" id="_psFlag" name="_psFlag">
											<option value="0"
												<c:if test="${param._psFlag eq '0'}">selected="selected"</c:if>>否</option>
											<option value="1"
												<c:if test="${param._psFlag eq '1'}">selected="selected"</c:if>>是</option>
										</select>
									</div>
								</div>

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 是否有备注: </span> <select
											class="form-control" id="_remark" name="_remark">
											<option value="-1"
												<c:if test="${param._remark eq '-1'}">selected="selected"</c:if>>全部</option>
											<option value="0"
												<c:if test="${param._remark eq '0'}">selected="selected"</c:if>>否</option>
											<option value="1"
												<c:if test="${param._remark eq '1'}">selected="selected"</c:if>>是</option>
										</select>
									</div>
								</div> 
								
								<div class="col-sm-3" style="display: none;">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 处理方式: </span>
										<select	class="form-control" id="_dealType" name="_dealType">
											<option value="1" selected="selected"> 批次处理 </option>
											<option value="0" >正常处理</option>
										</select>
									</div>
								</div>
								
								<div class="col-sm-2">
									<div class="input-group col-sm-12">
										<button class="btn btn-info" type="button"
											style="margin-left: 10px;" onclick="query(this);">搜索</button>
										<button class="btn btn-info" type="button"
											style="margin-left: 10px;"
											onclick="exceptRemarkOrdernos(this);">导出含备注订单</button>
									</div>
								</div>
							</div>

							<%-- <div class="form-group row">
							
							<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> sku: </span> 
										<input type="text" name="_sku"  id="_sku" class="form-control span3" value="${param._sku}" >
									</div>
								</div>
								
								<div class="col-sm-1">
									<div class="input-group col-sm-12">
										<button class="btn btn-info" type="button" style="margin-left: 10px;" onclick="query(this);">搜索</button>
									</div>
								</div>
							
							</div> --%>
							<!-- 						</td> -->
							<!-- 						</tr> -->
							<!-- 					</table> -->
						</form>

					</div>
				</div>
			</div>
		</div>




		<!-- 查询结果 start -->
		<div class="form-group row">
			<div class="col-md-12">

				<div class="nav-tabs-custom">
					<ul class="nav nav-tabs">
						<li class="${tab1}"><a href="#tab1" data-toggle="tab">单件订单<c:if
									test="${singleList.size()>0}">
									<span class="badge badge-success">${singleList.size()}</span>
								</c:if><span id="fold"></span>
						</a></li>
						<li class="${tab2}"><a href="#tab2" data-toggle="tab">多件订单<c:if
									test="${multiList.size()>0}">
									<span class="badge badge-success">${multiList.size()}</span>
								</c:if><span id="unfold"></span>
						</a></li>
					</ul>

					<div class="tab-content">

						<!-- tab1 单件订单------------------------------------------------------------------------->
						<div class="tab-pane ${tab1}" id="tab1">

							<form class="form-search" style="margin-top: 2px;">

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 运单: </span> <select
											class="form-control" id="single_billType"
											name="single_billType">
											<option value="cbill" selected="selected">普通运单</option>
											<c:if test="${userType eq 'paiu' }">
												<option value="ebill">电子运单</option>
											</c:if>
										</select>
									</div>
								</div>


								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text">作业模式: </span> <select
											class="form-control" id="single_flowType"
											name="single_flowType">
											<option value="prePrint" selected="selected">预先打单</option>
											<option value="intimePrint">及时打单</option>
										</select>
									</div>
								</div>

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text">每批订单数: </span> <select
											class="form-control" id="single_orderNum"
											name="single_orderNum">
											<option value="30">30</option>
											<option value="5">5</option>
											<option value="10">10</option>
											<option value="15">15</option>
											<option value="20">20</option>
											<option value="25">25</option>
											<option value="60">60</option>
											<option value="100">100</option>
											<option value="200">200</option>
											<option value="500">500</option>
											<option value="1000">1000</option>
										</select>
									</div>
								</div>


								<shiro:lacksRole name="分仓宝商家">
									<a data-toggle="modal" role="button" class="btn btn-primary"
										onclick="preWorkBatch_single();">生成分拣批次</a>
								</shiro:lacksRole>

								<a href="#preWorkBatch_single" data-toggle="modal" role="button"
									id="single_preWorkBatch" style="display: none;"
									class="btn btn-primary"></a>
							</form>
							<div style="height: 10px;"></div>


							<%-- 		<c:if test="${singleListMore>0}">最多显示1000条,隐藏了${singleListMore-1000}条数据</c:if> --%>
							<table id="contentTable"
								class="table table-striped table-bordered table-condensed">
								<thead>
									<tr>
										<th><input type="checkbox" name="single_myCheckedAll"
											id="single_myCheckedAll" /> <!-- 					      onclick="myCheckedAll('single')"  -->
										</th>
										<th>序号</th>
										<th>商家编码</th>
										<th>订单号</th>
										<th>来源店铺</th>
										<th>收货人</th>
										<th>目的地</th>
										<th>是否优先派送</th>
										<th>指定快递公司</th>
										<th>备注</th>
										<th>审单时间</th>
										<th>总重量</th>
										<th>sku</th>
										<th>查询操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${singleList}" var="o" varStatus="i">
										<tr id="tr_single_${o.ordeno}">
											<td align="right"><input type="checkbox"
												name="single_myChecked" id="single_${o.ordeno}"
												value="${o.ordeno}" /> <%-- 						  onclick="myChecked('single','${o.ordeno}')" --%>
											</td>
											<td>${i.count}</td>
											<td>${o.customerCode}</td>
											<td id="single_ordeno_${o.ordeno}">${o.ordeno}</td>
											<td id="single_shopna_${o.ordeno}">${o.shopna}</td>
											<td id="single_recena_${o.ordeno}">${o.recena}</td>
											<td id="single_addres_${o.ordeno}">${o.addres}</td>
											<td id="single_psFlag_${o.ordeno}"><c:if
													test="${o.prioritySendFlag eq '1'}">是</c:if> <c:if
													test="${o.prioritySendFlag eq '0'}">否</c:if></td>
											<td id="single_cacode_${o.ordeno}">${o.cacode}</td>
											<td id="single_remark_${o.ordeno}">${o.bumemo}</td>
											<td id="single_crtime_${o.ordeno}">${fn:substring(o.crtime,0,19)}</td>
											<td id="multi_total_${o.ordeno}">${o.totalWeight}g</td>
											<td id="single_sku_${o.ordeno}">${o.sku}</td>
											<td><a href="#ordersDetailed"
												onclick="getAjaxOrders('${o.id}')" role="button"
												class="btn btn-small btn-primary" data-toggle="modal">订单详情
											</a> <a href="#itemsDetailed" onclick="getAjaxItems('${o.id}')"
												role="button" class="btn btn-small btn-primary"
												data-toggle="modal"> 商品详情 </a></td>
										</tr>
									</c:forEach>
								</tbody>
							</table>

						</div>

						<!-- tab2 多件商品------------------------------------------------------------------------->
						<div class="tab-pane ${tab2}" id="tab2">

							<form class="form-search" style="margin-top: 2px;">

								<!-- 				 <label style="margin-left: 10px;">仓库:</label> -->
								<!-- 				 <select  name="multi_warehouseCode"  id="multi_warehouseCode" class="input-small"> -->
								<!-- 					<option value=""></option> -->
								<!-- 					<c:forEach items="${warehouseList}" var="w" > -->
								<!-- 					   <option value="${w.groupCode}" >${w.groupName}</option> -->
								<!-- 				   </c:forEach> -->
								<!-- 				</select> -->

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text"> 运单: </span> <select
											class="form-control" id="multi_billType"
											name="multi_billType">
											<option value="cbill" selected="selected">普通运单</option>
											<c:if test="${userType eq 'paiu' }">
												<option value="ebill">电子运单</option>
											</c:if>
										</select>
									</div>
								</div>


								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text">作业模式: </span> <select
											class="form-control" id="multi_flowType"
											name="multi_flowType">
											<option value="prePrint" selected="selected">预先打单</option>
											<option value="intimePrint">及时打单</option>
										</select>
									</div>
								</div>

								<div class="col-sm-3">
									<div class="input-group col-sm-12">
										<span class="input-group-text">每批订单数: </span> <select
											class="form-control" id="multi_orderNum"
											name="multi_orderNum">
											<option value="30">30</option>
											<option value="15">15</option>
											<option value="3">3</option>
											<option value="5">5</option>
											<option value="10">10</option>
											<option value="20">20</option>
											<option value="24">24</option>
											<option value="25">25</option>
											<option value="45">45</option>
											<option value="48">48</option>
											<option value="60">60</option>
											<option value="90">90</option>
											<option value="100">100</option>
											<option value="200">200</option>
											<option value="500">500</option>
											<option value="1000">1000</option>
										</select>
									</div>
								</div>


								<%-- 				<shiro:lacksRole name="分仓宝商家"> --%>
								<a data-toggle="modal" role="button" class="btn btn-primary"
									onclick="preWorkBatch_multi();">生成分拣批次</a>
								<%-- 				</shiro:lacksRole> --%>

								<a href="#preWorkBatch_multi" data-toggle="modal" role="button"
									id="multi_preWorkBatch" style="display: none;"
									class="btn btn-primary"></a>

							</form>
							<div style="height: 10px;"></div>
							<%-- 				<c:if test="${multiListMore>0}">最多显示1000条,隐藏了${multiListMore-1000}条数据</c:if> --%>
							<table id="contentTable"
								class="table table-striped table-bordered table-condensed">
								<thead>
									<tr>
										<th><input type="checkbox" name="multi_myCheckedAll"
											id="multi_myCheckedAll" onclick="myCheckedAll('multi')" /></th>
										<th>序号</th>
										<th>商家编码</th>
										<th>订单号</th>
										<th>来源店铺</th>
										<th>收货人</th>
										<th>目的地</th>
										<th>是否优先派送</th>
										<th>指定快递公司</th>
										<th>备注</th>
										<th>总重量</th>
										<th>sku</th>
										<th>审单时间</th>
										<th>查询操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${multiList}" var="o" varStatus="i">
										<tr>
											<td align="right"><input type="checkbox"
												name="multi_myChecked" id="multi_${o.ordeno}"
												value="${o.ordeno}"
												onclick="myChecked('multi','${o.ordeno}')" /></td>
											<td>${i.count}</td>
											<td>${o.customerCode}</td>
											<td id="multi_ordeno_${o.ordeno}">${o.ordeno}</td>
											<td id="multi_shopna_${o.ordeno}">${o.shopna}</td>
											<td id="multi_recena_${o.ordeno}">${o.recena}</td>
											<td id="multi_addres_${o.ordeno}">${o.addres}</td>
											<td id="single_psFlag_${o.ordeno}"><c:if
													test="${o.prioritySendFlag eq '1'}">是</c:if> <c:if
													test="${o.prioritySendFlag eq '0'}">否</c:if></td>
											<td id="multi_cacode_${o.ordeno}">${o.cacode}</td>
											<td id="multi_remark_${o.ordeno}">${o.bumemo}</td>
											<td id="multi_total_${o.ordeno}">${o.totalWeight}g</td>
											<td id="multi_sku_${o.ordeno}">${o.sku}</td>
											<td id="multi_crtime_${o.ordeno}">${fn:substring(o.crtime,0,19)}</td>
											<td><a href="#ordersDetailed"
												onclick="getAjaxOrders('${o.id}')" role="button"
												class="btn btn-small btn-primary" data-toggle="modal">
													订单详情 </a> <a href="#itemsDetailed"
												onclick="getAjaxItems('${o.id}')" role="button"
												class="btn btn-small btn-primary" data-toggle="modal">
													商品详情 </a></td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>

					</div>
					<!-- tab content -->

				</div>
				<!-- tab table -->

			</div>
		</div>

		<!-- 订单详细信息  窗体-->
		<div class="modal fade" tabindex="-1" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true" id="ordersDetailed">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<h3>订单详细信息</h3>
					</div>
					<div class="modal-body" style="overflow: auto; height: 500px;">
						<table class="table table-striped table-bordered table-condensed"
							id="modalBodyOrders"></table>
					</div>
					<div class="modal-footer">
						<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
					</div>
				</div>
			</div>
		</div>

		<!-- 商品详细信息 窗体 -->
		<div class="modal fade" tabindex="-1" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true" id="itemsDetailed">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<h3>商品详细信息</h3>
					</div>
					<div class="modal-body" style="overflow: auto;">
						<table class="table table-striped table-bordered table-condensed"
							id="modalBodyItems"></table>
					</div>
					<div class="modal-footer">
						<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
					</div>
				</div>
			</div>
		</div>



		<!-- 批次预览_单件 窗体 -->
		<div class="modal  fade" tabindex="-1" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true"
			id="preWorkBatch_single">

			<div class="modal-dialog">
				<div class="modal-content" style="width: 700px; overflow: auto;">
					<div class="modal-header">
						<h3>单件作业批次 预览</h3>
					</div>
					<div class="modal-body" id="preContent_single"
						style="height: 400px; width: 680px; overflow: auto;"></div>
					<div class="modal-footer">
						<button id="btn_createWorkBatch_single" class="btn btn-primary"
							aria-hidden="true" onclick="createWorkBatch_single(-1,this);">确定创建</button>
						<button id="btn_cancel_single" class="btn" data-dismiss="modal"
							aria-hidden="true">返回</button>
					</div>
				</div>
			</div>


		</div>

		<!-- 批次预览_多件 窗体 -->
		<div class="modal  fade" tabindex="-1" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true"
			id="preWorkBatch_multi">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<h3>多件作业批次 预览</h3>
					</div>
					<div class="modal-body" id="preContent_multi"
						style="height: 400px; overflow: auto;"></div>
					<div class="modal-footer">
						<button id="btn_createWorkBatch_multi" class="btn btn-primary"
							aria-hidden="true" onclick="createWorkBatch_multi();">确定创建</button>
						<button id="btn_cancel_multi" class="btn" data-dismiss="modal"
							aria-hidden="true" onclick="closeMultiModal();">返回</button>
					</div>
				</div>
			</div>


		</div>

	</section>

</body>
</html>
